package com.he.architecture.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.he.architecture.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
//订单
public class CustomerOrder extends LogicEntity {
    @Column
    private Double orderTotal;

    @Column(columnDefinition="INT default 1")
    private Integer orderType;

    //订单与流水的一对多关系
    @OneToMany(mappedBy = "customerOrder",
            fetch = FetchType.LAZY,
            orphanRemoval = true,
            cascade = CascadeType.ALL)
    @JsonIgnore
    private Set<LineItem> lineItems;
    //订单与门店的多对一关系
    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"customerOrders"})
    private Shop shop;

    //订单与顾客的多对一关系
    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"customerOrders"})
    private Customer customer;

}
